<?php
if (!function_exists("dameCampo")){
    function dameCampo($nombre,$valor,$queEs=0){
            //0->Normal; 1->Array; 2->Función
            if($valor==""){
                    return false;
            }
            else{
                    if($queEs==1)return $nombre.": [".$valor."]";
                    elseif($queEs==2)return $nombre.": ".$valor;
                    else return "$nombre: '$valor'";
            }
    }
}

class plotBands{
    private $color;
    private $from;
    private $id;
    private $to;

    function __construct($color="", $from="", $id="", $to="") {
        $this->color = $color;
        $this->from = $from;
        $this->id = $id;
        $this->to = $to;
    }

    public function getColor() {
        return $this->color;
    }

    public function getFrom() {
        return $this->from;
    }

    public function getId() {
        return $this->id;
    }

    public function getTo() {
        return $this->to;
    }

    public function setColor($color) {
        $this->color = $color;
    }

    public function setFrom($from) {
        $this->from = $from;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setTo($to) {
        $this->to = $to;
    }
}


    class plotLines{
       private $reversed;
       private $showFirstLabel;
       private $showLastLabel;
       private $startOfWeek;
       private $startOnTick;
       private $tickColor;
       private $tickInterval;
       private $tickLength;
       private $tickmarkPlacement;
       private $tickPixelInterval;
       private $tickPosition;
       private $tickWidth;

       function __construct($reversed=false, $showFirstLabel=true, $showLastLabel=false, $startOfWeek=1, $startOnTick=false, $tickColor="#C0D0E0", $tickInterval="auto",
                            $tickLength=5, $tickmarkPlacement="between", $tickPixelInterval="", $tickPosition="outside", $tickWidth=1) {
           $this->reversed = $reversed;
           $this->showFirstLabel = $showFirstLabel;
           $this->showLastLabel = $showLastLabel;
           $this->startOfWeek = $startOfWeek;
           $this->startOnTick = $startOnTick;
           $this->tickColor = $tickColor;
           $this->tickInterval = $tickInterval;
           $this->tickLength = $tickLength;
           $this->tickmarkPlacement = $tickmarkPlacement;
           $this->tickPixelInterval = $tickPixelInterval;
           $this->tickPosition = $tickPosition;
           $this->tickWidth = $tickWidth;
       }
       public function getReversed() {
           return $this->reversed;
       }

       public function getShowFirstLabel() {
           return $this->showFirstLabel;
       }

       public function getShowLastLabel() {
           return $this->showLastLabel;
       }

       public function getStartOfWeek() {
           return $this->startOfWeek;
       }

       public function getStartOnTick() {
           return $this->startOnTick;
       }

       public function getTickColor() {
           return $this->tickColor;
       }

       public function getTickInterval() {
           return $this->tickInterval;
       }

       public function getTickLength() {
           return $this->tickLength;
       }

       public function getTickmarkPlacement() {
           return $this->tickmarkPlacement;
       }

       public function getTickPixelInterval() {
           return $this->tickPixelInterval;
       }

       public function getTickPosition() {
           return $this->tickPosition;
       }

       public function getTickWidth() {
           return $this->tickWidth;
       }

       public function setReversed($reversed) {
           $this->reversed = $reversed;
       }

       public function setShowFirstLabel($showFirstLabel) {
           $this->showFirstLabel = $showFirstLabel;
       }

       public function setShowLastLabel($showLastLabel) {
           $this->showLastLabel = $showLastLabel;
       }

       public function setStartOfWeek($startOfWeek) {
           $this->startOfWeek = $startOfWeek;
       }

       public function setStartOnTick($startOnTick) {
           $this->startOnTick = $startOnTick;
       }

       public function setTickColor($tickColor) {
           $this->tickColor = $tickColor;
       }

       public function setTickInterval($tickInterval) {
           $this->tickInterval = $tickInterval;
       }

       public function setTickLength($tickLength) {
           $this->tickLength = $tickLength;
       }

       public function setTickmarkPlacement($tickmarkPlacement) {
           $this->tickmarkPlacement = $tickmarkPlacement;
       }

       public function setTickPixelInterval($tickPixelInterval) {
           $this->tickPixelInterval = $tickPixelInterval;
       }

       public function setTickPosition($tickPosition) {
           $this->tickPosition = $tickPosition;
       }

       public function setTickWidth($tickWidth) {
           $this->tickWidth = $tickWidth;
       }
    }


//objetos que estan dentro de las classes xAxis, yAxis,etc
    class labels{
        private $align;
        private $x;
        private $y;
        private $enabled;
        private $formatter="";
        private $rotation = 0;
        private $style = "";

        function __construct($align="right", $x=-8, $y=3, $enabled=true, $formatter="", $rotation=0, $style="") {
            $this->align = $align;
            $this->x = $x;
            $this->y = $y;
            $this->enabled = $enabled;
            $this->formatter = $formatter;
            $this->rotation = $rotation;
            $this->style = $style;
        }

        public function getAlign() {
            return $this->align;
        }

        public function getX() {
            return $this->x;
        }

        public function getY() {
            return $this->y;
        }

        public function getEnabled() {
            return $this->enabled;
        }

        public function getFormatter() {
            return $this->formatter;
        }

        public function getRotation() {
            return $this->rotation;
        }

        public function getStyle() {
            return $this->style;
        }

        public function setAlign($align) {
            $this->align = $align;
        }

        public function setX($x) {
            $this->x = $x;
        }

        public function setY($y) {
            $this->y = $y;
        }

        public function setEnabled($enabled) {
            $this->enabled = $enabled;
        }

        public function setFormatter($formatter) {
            $this->formatter = $formatter;
        }

        public function setRotation($rotation) {
            $this->rotation = $rotation;
        }

        public function setStyle($style) {
            $this->style = $style;
        }
    }


    class xAxis{
        private $alternateGridColor;
        private $categories;
        private $dateTimeLabelFormats;
        private $endOnTick;
        private $gridLineColor;
        private $gridLineWidth;
        private $id;
        private $labels;
        private $lineColor;
        private $lineWidth;
        private $max;
        private $maxPadding;
        private $maxZoom;
        private $min;
        private $minorGridLineColor;
        private $minorGridLineWidth;
        private $minorTickColor;
        private $minorTickInterval;
        private $minorTickLength;
        private $minorTickPosition;
        private $minorTickWidth;
        private $minPadding;
        private $offset;
        private $opposite;
        private $reversed;
        private $showFirstLabel;
        private $showLastLabel;
        private $startOfWeek;
        private $startOnTick;
        private $tickColor;
        private $tickInterval;
        private $tickLength;
        private $tickmarkPlacement;
        private $tickPixelInterval;
        private $tickPosition;
        private $tickWidth;
        private $title;
        private $type;

    /**
     * @TODO: No funciona $xAxis = new xAxis($categories = "'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'");
     */
      function __construct($labels="",$alternateGridColor="#000000", $categories="",
                                                     $dateTimeLabelFormats=",", $endOnTick='false', $gridLineColor="#C0C0C0",$tickWidth=1, $title=0, $type="linear",
                             $gridLineWidth=0, $id="", $lineColor="#C0D0E0", $lineWidth=1, $max="", $maxPadding=0, $maxZoom=1, $min="",
                             $minorGridLineColor="#E0E0E0", $minorGridLineWidth=1, $minorTickColor="#A0A0A0", $minorTickInterval="",
                             $minorTickLength=2, $minorTickPosition="outside", $minorTickWidth=1, $minPadding=0, $offset=0, $opposite='false',
                             $reversed='', $showFirstLabel='true', $showLastLabel='false', $startOfWeek=1, $startOnTick='false', $tickColor="#C0C0C0",
                             $tickInterval="", $tickLength=5, $tickmarkPlacement="between", $tickPixelInterval="", $tickPosition="outside")
                     {

                          $this->alternateGridColor = $alternateGridColor;
                          $this->categories = $categories;
                         // echo "categorias constructor:".$this->categories;
                          $this->dateTimeLabelFormats = $dateTimeLabelFormats;
                          $this->endOnTick = $endOnTick;
                          $this->gridLineColor = $gridLineColor;
                          $this->gridLineWidth = $gridLineWidth;
                          if ($labels == 0)     $this->labels = new labels();
                          else $this->labels = $label;
                          $this->labels =
                          $this->id = $id;
                          $this->lineColor = $lineColor;
                          $this->lineWidth = $lineWidth;
                          $this->max = $max;
                          $this->maxPadding = $maxPadding;
                          $this->maxZoom = $maxZoom;
                          $this->min = $min;
                          $this->minorGridLineColor = $minorGridLineColor;
                          $this->minorGridLineWidth = $minorGridLineWidth;
                          $this->minorTickColor = $minorTickColor;
                          $this->minorTickInterval = $minorTickInterval;
                          $this->minorTickLength = $minorTickLength;
                          $this->minorTickPosition = $minorTickPosition;
                          $this->minorTickWidth = $minorTickWidth;
                          $this->minPadding = $minPadding;
                          $this->offset = $offset;
                          $this->opposite = $opposite;
                          $this->reversed = $reversed;
                          $this->showFirstLabel = $showFirstLabel;
                          $this->showLastLabel = $showLastLabel;
                          $this->startOfWeek = $startOfWeek;
                          $this->startOnTick = $startOnTick;
                          $this->tickColor = $tickColor;
                          $this->tickInterval = $tickInterval;
                          $this->tickLength = $tickLength;
                          $this->tickmarkPlacement = $tickmarkPlacement;
                          $this->tickPixelInterval = $tickPixelInterval;
                          $this->tickPosition = $tickPosition;
                          $this->tickWidth = $tickWidth;
                          if ($title == 0) $this->title = new title();
                          else $this->title = $title;
                          $this->type = $type;
      }
     public function getAlternateGridColor() {
         return $this->alternateGridColor;
     }

     public function getCategories() {
         return $this->categories;
     }

     public function getDateTimeLabelFormats() {
         return $this->dateTimeLabelFormats;
     }

     public function getEndOnTick() {
         return $this->endOnTick;
     }

     public function getGridLineColor() {
         return $this->gridLineColor;
     }

     public function getGridLineWidth() {
         return $this->gridLineWidth;
     }

     public function getId() {
         return $this->id;
     }

     public function getLabels() {
         return $this->labels;
     }

     public function getLineColor() {
         return $this->lineColor;
     }

     public function getLineWidth() {
         return $this->lineWidth;
     }

     public function getMax() {
         return $this->max;
     }

     public function getMaxPadding() {
         return $this->maxPadding;
     }

     public function getMaxZoom() {
         return $this->maxZoom;
     }

     public function getMin() {
         return $this->min;
     }

     public function getMinorGridLineColor() {
         return $this->minorGridLineColor;
     }

     public function getMinorGridLineWidth() {
         return $this->minorGridLineWidth;
     }

     public function getMinorTickColor() {
         return $this->minorTickColor;
     }

     public function getMinorTickInterval() {
         return $this->minorTickInterval;
     }

     public function getMinorTickLength() {
         return $this->minorTickLength;
     }

     public function getMinorTickPosition() {
         return $this->minorTickPosition;
     }

     public function getMinorTickWidth() {
         return $this->minorTickWidth;
     }

     public function getMinPadding() {
         return $this->minPadding;
     }

     public function getOffset() {
         return $this->offset;
     }

     public function getOpposite() {
         return $this->opposite;
     }

     public function getReversed() {
         return $this->reversed;
     }

     public function getShowFirstLabel() {
         return $this->showFirstLabel;
     }

     public function getShowLastLabel() {
         return $this->showLastLabel;
     }

     public function getStartOfWeek() {
         return $this->startOfWeek;
     }

     public function getStartOnTick() {
         return $this->startOnTick;
     }

     public function getTickColor() {
         return $this->tickColor;
     }

     public function getTickInterval() {
         return $this->tickInterval;
     }

     public function getTickLength() {
         return $this->tickLength;
     }

     public function getTickmarkPlacement() {
         return $this->tickmarkPlacement;
     }

     public function getTickPixelInterval() {
         return $this->tickPixelInterval;
     }

     public function getTickPosition() {
         return $this->tickPosition;
     }

     public function getTickWidth() {
         return $this->tickWidth;
     }

     public function getTitle() {
         return $this->title;
     }

     public function getType() {
         return $this->type;
     }

     public function setAlternateGridColor($alternateGridColor) {
         $this->alternateGridColor = $alternateGridColor;
     }

     public function setCategories($categories) {
         $this->categories = $categories;
     }

     public function setDateTimeLabelFormats($dateTimeLabelFormats) {
         $this->dateTimeLabelFormats = $dateTimeLabelFormats;
     }

     public function setEndOnTick($endOnTick) {
         $this->endOnTick = $endOnTick;
     }

     public function setGridLineColor($gridLineColor) {
         $this->gridLineColor = $gridLineColor;
     }

     public function setGridLineWidth($gridLineWidth) {
         $this->gridLineWidth = $gridLineWidth;
     }

     public function setId($id) {
         $this->id = $id;
     }

     public function setLabels($labels) {
         $this->labels = $labels;
     }

     public function setLineColor($lineColor) {
         $this->lineColor = $lineColor;
     }

     public function setLineWidth($lineWidth) {
         $this->lineWidth = $lineWidth;
     }

     public function setMax($max) {
         $this->max = $max;
     }

     public function setMaxPadding($maxPadding) {
         $this->maxPadding = $maxPadding;
     }

     public function setMaxZoom($maxZoom) {
         $this->maxZoom = $maxZoom;
     }

     public function setMin($min) {
         $this->min = $min;
     }

     public function setMinorGridLineColor($minorGridLineColor) {
         $this->minorGridLineColor = $minorGridLineColor;
     }

     public function setMinorGridLineWidth($minorGridLineWidth) {
         $this->minorGridLineWidth = $minorGridLineWidth;
     }

     public function setMinorTickColor($minorTickColor) {
         $this->minorTickColor = $minorTickColor;
     }

     public function setMinorTickInterval($minorTickInterval) {
         $this->minorTickInterval = $minorTickInterval;
     }

     public function setMinorTickLength($minorTickLength) {
         $this->minorTickLength = $minorTickLength;
     }

     public function setMinorTickPosition($minorTickPosition) {
         $this->minorTickPosition = $minorTickPosition;
     }

     public function setMinorTickWidth($minorTickWidth) {
         $this->minorTickWidth = $minorTickWidth;
     }

     public function setMinPadding($minPadding) {
         $this->minPadding = $minPadding;
     }

     public function setOffset($offset) {
         $this->offset = $offset;
     }

     public function setOpposite($opposite) {
         $this->opposite = $opposite;
     }

     public function setReversed($reversed) {
         $this->reversed = $reversed;
     }

     public function setShowFirstLabel($showFirstLabel) {
         $this->showFirstLabel = $showFirstLabel;
     }

     public function setShowLastLabel($showLastLabel) {
         $this->showLastLabel = $showLastLabel;
     }

     public function setStartOfWeek($startOfWeek) {
         $this->startOfWeek = $startOfWeek;
     }

     public function setStartOnTick($startOnTick) {
         $this->startOnTick = $startOnTick;
     }

     public function setTickColor($tickColor) {
         $this->tickColor = $tickColor;
     }

     public function setTickInterval($tickInterval) {
         $this->tickInterval = $tickInterval;
     }

     public function setTickLength($tickLength) {
         $this->tickLength = $tickLength;
     }

     public function setTickmarkPlacement($tickmarkPlacement) {
         $this->tickmarkPlacement = $tickmarkPlacement;
     }

     public function setTickPixelInterval($tickPixelInterval) {
         $this->tickPixelInterval = $tickPixelInterval;
     }

     public function setTickPosition($tickPosition) {
         $this->tickPosition = $tickPosition;
     }

     public function setTickWidth($tickWidth) {
         $this->tickWidth = $tickWidth;
     }

     public function setTitle($title) {
         $this->title = $title;
     }

     public function setType($type) {
         $this->type = $type;
     }

    }


    class yAxis{
        private $labels;
        private $endOnTick;
        private $gridLineWidth;
        private $lineWidth;
        private $maxPadding;
        private $minPadding;
        private $showLastLabel;
        private $startOnTick;
        private $tickWidth;
        private $alternateGridColor;
        private $categories;
        private $dateTimeLabelFormats;
        private $events;
        private $gridLineColor;
        private $id;
        private $lineColor;
        private $max;
        private $maxZoom;
        private $min;
        private $minorGridLineColor;
        private $minorGridLineWidth;
        private $minorTickColor;
        private $minorTickInterval;
        private $minorTickLength;
        private $minorTickPosition;
        private $minorTickWidth;
        private $offset;
        private $opposite;
        private $reversed;
        private $showFirstLabel;
        private $prstartOfWeek;
        private $tickColor;
        private $tickInterval;
        private $tickLength;
        private $tickmarkPlacement;
        private $tickPixelInterval;
        private $tickPosition;
        private $type;
        private $title;
        private $color; // color de la columna!!!
        private $unidadMedida;
        private $queMide;
        private $margin;

        function __construct($offset="-1", $opposite=false,$margin=10,$queMide='algo por hora',$unidadMedida="algo/h",$color="#CCCCCC",$labels=0,$endOnTick=true, $gridLineWidth=1, $lineWidth=0, $maxPadding=0.05, $minPadding=0.05, $showLastLabel=true, $startOnTick=true,
                             $tickWidth=0, $alternateGridColor="", $categories="", $dateTimeLabelFormats="", $gridLineColor="#C0C0C0", $id="", $lineColor="#C0D0E0",
                             $max="", $maxZoom=1, $min="", $minorGridLineColor="#E0E0E0", $minorGridLineWidth=1, $minorTickColor="#A0A0A0", $minorTickInterval="",
                             $minorTickLength=2, $minorTickPosition="outside", $minorTickWidth=1,  $reversed=false, $showFirstLabel=true,
                             $prstartOfWeek=1, $tickColor="#C0D0E0", $tickInterval="auto", $tickLength=5, $tickmarkPlacement="between", $tickPixelInterval="", $tickPosition="outside",
                             $type="linear", $title=0) {

            $this->endOnTick = $endOnTick;
            $this->gridLineWidth = $gridLineWidth;
            $this->lineWidth = $lineWidth;
            $this->maxPadding = $maxPadding;
            $this->minPadding = $minPadding;
            $this->showLastLabel = $showLastLabel;
            $this->startOnTick = $startOnTick;
            $this->tickWidth = $tickWidth;
            $this->alternateGridColor = $alternateGridColor;
            $this->categories = $categories;
            $this->dateTimeLabelFormats = $dateTimeLabelFormats;
            $this->events = $events;
            $this->gridLineColor = $gridLineColor;
            $this->id = $id;
            $this->lineColor = $lineColor;
            $this->max = $max;
            $this->maxZoom = $maxZoom;
            $this->min = $min;
            $this->minorGridLineColor = $minorGridLineColor;
            $this->minorGridLineWidth = $minorGridLineWidth;
            $this->minorTickColor = $minorTickColor;
            $this->minorTickInterval = $minorTickInterval;
            $this->minorTickLength = $minorTickLength;
            $this->minorTickPosition = $minorTickPosition;
            $this->minorTickWidth = $minorTickWidth;
            $this->offset = $offset;
            $this->opposite = $opposite;
            $this->reversed = $reversed;
            $this->showFirstLabel = $showFirstLabel;
            $this->prstartOfWeek = $prstartOfWeek;
            $this->tickColor = $tickColor;
            $this->tickInterval = $tickInterval;
            $this->tickLength = $tickLength;
            $this->tickmarkPlacement = $tickmarkPlacement;
            $this->tickPixelInterval = $tickPixelInterval;
            $this->tickPosition = $tickPosition;
            $this->type = $type;
            if ($title == 0) $this->title = new title();
            else $this->title = $title;
            if($labels == 0) $this->labels = new labels();
            else $this->labels = $labels;
            $this->color = $color;
            $this->unidadMedida = $unidadMedida;
            $this->queMide = $queMide;
            $this->margin = $margin;

        }

        public function getQueMide() {
            return $this->queMide;
        }

        public function getUnidadMedida() {
            return $this->unidadMedida;
        }

        public function getColor() {
            return $this->color;
        }

        public function getLabels() {
            return $this->labels;
        }

        public function getEndOnTick() {
            return $this->endOnTick;
        }

        public function getGridLineWidth() {
            return $this->gridLineWidth;
        }

        public function getLineWidth() {
            return $this->lineWidth;
        }

        public function getMargin(){
            return $this->margin;
        }

        public function setMargin($var){
            $this->margin = $var;
        }
        public function getMaxPadding() {
            return $this->maxPadding;
        }

        public function getMinPadding() {
            return $this->minPadding;
        }

        public function getShowLastLabel() {
            return $this->showLastLabel;
        }

        public function getStartOnTick() {
            return $this->startOnTick;
        }

        public function getTickWidth() {
            return $this->tickWidth;
        }

        public function getAlternateGridColor() {
            return $this->alternateGridColor;
        }

        public function getCategories() {
            return $this->categories;
        }

        public function getDateTimeLabelFormats() {
            return $this->dateTimeLabelFormats;
        }

        public function getEvents() {
            return $this->events;
        }

        public function getGridLineColor() {
            return $this->gridLineColor;
        }

        public function getId() {
            return $this->id;
        }

        public function getLineColor() {
            return $this->lineColor;
        }

        public function getMax() {
            return $this->max;
        }

        public function getMaxZoom() {
            return $this->maxZoom;
        }

        public function getMin() {
            return $this->min;
        }

        public function getMinorGridLineColor() {
            return $this->minorGridLineColor;
        }

        public function getMinorGridLineWidth() {
            return $this->minorGridLineWidth;
        }

        public function getMinorTickColor() {
            return $this->minorTickColor;
        }

        public function getMinorTickInterval() {
            return $this->minorTickInterval;
        }

        public function getMinorTickLength() {
            return $this->minorTickLength;
        }

        public function getMinorTickPosition() {
            return $this->minorTickPosition;
        }

        public function getMinorTickWidth() {
            return $this->minorTickWidth;
        }

        public function getOffset() {
            return $this->offset;
        }

        public function getOpposite() {
            return $this->opposite;
        }

        public function getReversed() {
            return $this->reversed;
        }

        public function getShowFirstLabel() {
            return $this->showFirstLabel;
        }

        public function getPrstartOfWeek() {
            return $this->prstartOfWeek;
        }

        public function getTickColor() {
            return $this->tickColor;
        }

        public function getTickInterval() {
            return $this->tickInterval;
        }

        public function getTickLength() {
            return $this->tickLength;
        }

        public function getTickmarkPlacement() {
            return $this->tickmarkPlacement;
        }

        public function getTickPixelInterval() {
            return $this->tickPixelInterval;
        }

        public function getTickPosition() {
            return $this->tickPosition;
        }

        public function getType() {
            return $this->type;
        }

        public function getTitle() {
            return $this->title;
        }

        public function setUnidadMedida($unidadMedida) {
            $this->unidadMedida = $unidadMedida;
        }

        public function setQueMide($queMide) {
            $this->queMide = $queMide;
        }

        public function setUnidad_medida($unidad_medida) {
            $this->unidad_medida = $unidad_medida;
        }

        public function setLabels($labels) {
            $this->labels = $labels;
        }

        public function setColor($color) {
            $this->color = $color;
        }

        public function setEndOnTick($endOnTick) {
            $this->endOnTick = $endOnTick;
        }

        public function setGridLineWidth($gridLineWidth) {
            $this->gridLineWidth = $gridLineWidth;
        }

        public function setLineWidth($lineWidth) {
            $this->lineWidth = $lineWidth;
        }

        public function setMaxPadding($maxPadding) {
            $this->maxPadding = $maxPadding;
        }

        public function setMinPadding($minPadding) {
            $this->minPadding = $minPadding;
        }

        public function setShowLastLabel($showLastLabel) {
            $this->showLastLabel = $showLastLabel;
        }

        public function setStartOnTick($startOnTick) {
            $this->startOnTick = $startOnTick;
        }

        public function setTickWidth($tickWidth) {
            $this->tickWidth = $tickWidth;
        }

        public function setAlternateGridColor($alternateGridColor) {
            $this->alternateGridColor = $alternateGridColor;
        }

        public function setCategories($categories) {
            $this->categories = $categories;
        }

        public function setDateTimeLabelFormats($dateTimeLabelFormats) {
            $this->dateTimeLabelFormats = $dateTimeLabelFormats;
        }

        public function setEvents($events) {
            $this->events = $events;
        }

        public function setGridLineColor($gridLineColor) {
            $this->gridLineColor = $gridLineColor;
        }

        public function setId($id) {
            $this->id = $id;
        }

        public function setLineColor($lineColor) {
            $this->lineColor = $lineColor;
        }

        public function setMax($max) {
            $this->max = $max;
        }

        public function setMaxZoom($maxZoom) {
            $this->maxZoom = $maxZoom;
        }

        public function setMin($min) {
            $this->min = $min;
        }

        public function setMinorGridLineColor($minorGridLineColor) {
            $this->minorGridLineColor = $minorGridLineColor;
        }

        public function setMinorGridLineWidth($minorGridLineWidth) {
            $this->minorGridLineWidth = $minorGridLineWidth;
        }

        public function setMinorTickColor($minorTickColor) {
            $this->minorTickColor = $minorTickColor;
        }

        public function setMinorTickInterval($minorTickInterval) {
            $this->minorTickInterval = $minorTickInterval;
        }

        public function setMinorTickLength($minorTickLength) {
            $this->minorTickLength = $minorTickLength;
        }

        public function setMinorTickPosition($minorTickPosition) {
            $this->minorTickPosition = $minorTickPosition;
        }

        public function setMinorTickWidth($minorTickWidth) {
            $this->minorTickWidth = $minorTickWidth;
        }

        public function setOffset($offset) {
            $this->offset = $offset;
        }

        public function setOpposite($opposite) {
            $this->opposite = $opposite;
        }

        public function setReversed($reversed) {
            $this->reversed = $reversed;
        }

        public function setShowFirstLabel($showFirstLabel) {
            $this->showFirstLabel = $showFirstLabel;
        }

        public function setPrstartOfWeek($prstartOfWeek) {
            $this->prstartOfWeek = $prstartOfWeek;
        }

        public function setTickColor($tickColor) {
            $this->tickColor = $tickColor;
        }

        public function setTickInterval($tickInterval) {
            $this->tickInterval = $tickInterval;
        }

        public function setTickLength($tickLength) {
            $this->tickLength = $tickLength;
        }

        public function setTickmarkPlacement($tickmarkPlacement) {
            $this->tickmarkPlacement = $tickmarkPlacement;
        }

        public function setTickPixelInterval($tickPixelInterval) {
            $this->tickPixelInterval = $tickPixelInterval;
        }

        public function setTickPosition($tickPosition) {
            $this->tickPosition = $tickPosition;
        }

        public function setType($type) {
            $this->type = $type;
        }

        public function setTitle($title) {
            $this->title = $title;
        }
}


class series{
        public $data;    //array de numero
        private $dataParser;
        private $dataURL;
		private $type;
		private $name;
		private $xAxis;
		private $yAxis;
		private $color;
		private $pointInterval;
		private $pointStart;
		private $visible;
		

               function __construct($color="#CCCCCC", $dataParser="", $dataURL="", $type="line", $name="", $xAxis=0, $yAxis=0,$data="",$pointInterval="",$pointStart="",$visible="true") {
                   $this->data = $data;
                   $this->dataParser = $dataParser;
                   $this->dataURL = $dataURL;
                   $this->type = $type;
                   $this->name = $name;
                   $this->xAxis = $xAxis;
                   $this->yAxis = $yAxis;
                   $this->color = $color;
                   $this->pointInterval = $pointInterval;
                   $this->pointStart = $pointStart;
                   $this->visible=$visible;
               }
               public function getData() {
                   return $this->data;
               }

               public function getDataParser() {
                   return $this->dataParser;
               }

               public function getDataURL() {
                   return $this->dataURL;
               }

               public function getColor() {
                   return $this->color;
               }


                public function getType() {
                    return $this->type;
                }

                public function getName() {
                    return $this->name;
                }

                public function getPointInterval() {
                    return $this->pointInterval;
                }

                public function getXAxis() {
                    return $this->xAxis;
                }

                public function getYAxis() {
                    return $this->yAxis;
                }

                public function getPointStart() {
                    return $this->pointStart;
                }

                public function getEjeX() {
                    return $this->ejeX;
                }

                public function getArrayDatos() {
                    return $this->arrayDatos;
                }

                public function getVisible() {
                    return $this->visible;
                }
                
                public function setData($data) {
                    $this->data = $data;
                }

                public function setDataParser($dataParser) {
                    $this->dataParser = $dataParser;
                }

                public function setDataURL($dataURL) {
                    $this->dataURL = $dataURL;
                }

                public function setColor($color) {
                    $this->color = $color;
                }
                
                public function setType($type) {
                    $this->type = $type;
                }

                public function setName($name) {
                    $this->name = $name;
                }

                public function setPointInterval($pointInterval) {
                    $this->pointInterval = $pointInterval;
                }

                public function setXAxis($xAxis) {
                    $this->xAxis = $xAxis;
                }

                public function setYAxis($yAxis) {
                    $this->yAxis = $yAxis;
                }

                public function setPointStart($pointStart) {
                    $this->pointStart = $pointStart;
                }

                public function setEjeX($ejeX) {
                    $this->ejeX = $ejeX;
                }

                public function setArrayDatos($arrayDatos) {
                    $this->arrayDatos = $arrayDatos;
                }
                
                public function setVisible($visible) {
                    $this->visible = $visible;
                }

}
	
class chart{
        private $renderTo;
		private $alignticks;
		private $backgroundcolor;
		private $borderColor;
		private $borderRadius;
		private $borderWidth;
		private $className;
		private $defaultSeriesType;
		private $height;
		private $ignoreHiddenSeries;
		private $inverted;
		private $margin;
		private $plotBackgroundColor;
		private $plotBackgroundImage;
		private $plotBorderColor;
		private $plotBorderWidth;
		private $plotShadow;
		private $shadow;
		private $showAxes;
		private $style;
		private $width;
		private $zoomType;
		private $events;
		private $codigoExtra;
	
	/** NO ESTA EVENTS
	 * @TODO: Pasa lo mismo que con opposite, no se inicializa bien! Fix it!
	 * **/
	public function chart($renderTo="container",$alignticks=true,$backgroundcolor="",$bordercolor='#4572A7',$borderradius=5,$borderwidth=0,$classname='',$defaultSeriesType='line',
				$height="",$ignoresHiddenSeries=true,$inverted=false,$margin="80,200,60,200",$plotbackgroundcolor="",$plotbackgroundimage="",
				$plotbordercolor='$C0C0C0',$plotborderwidth=0,$plotShadow=0,$shadow=false,$showAxes=false,$style="",$width="",$zoomtype='x',$events="",$codigoExtra=""){
				$this->renderTo = $renderTo;
				$this->alignticks = $alignticks;
				$this->backgroundcolor = $backgroundcolor;
				$this->borderColor = $bordercolor;
				$this->borderRadius = $borderradius;
				$this->borderWidth  = $borderwidth;
				$this->className = $className;
				$this->defaultSeriesType = $defaultSeriesType;
				$this->height = $height;
				$this->ignoreHiddenSeries = $ignoresHiddenSeries;
				$this->inverted = $inverted;
				$this->margin = $margin;
				$this->plotBackgroundColor = $plotbackgroundcolor;
				$this->plotBackgroundImage = $plotbackgroundimage;
				$this->plotBorderColor = $plotbordercolor;
				$this->plotBorderWidth = $plotborderwidth;
				$this->plotShadow = $plotShadow;
				$this->shadow = $shadow;
				$this->showAxes = $showAxes;
				$this->style = $style;
				$this->width = $width;
				$this->zoomType = $zoomtype;
				$this->events=$events;
				$this->codigoExtra=$codigoExtra;
	}

        public function getAlignticks() {
            return $this->alignticks;
        }

        public function getBackgroundcolor() {
            return $this->backgroundcolor;
        }

        public function getBorderColor() {
            return $this->borderColor;
        }

        public function getBorderRadius() {
            return $this->borderRadius;
        }

        public function getBorderWidth() {
            return $this->borderWidth;
        }

        public function getClassName() {
            return $this->className;
        }

        public function getDefaultSeriesType() {
            return $this->defaultSeriesType;
        }

        public function getHeight() {
            return $this->height;
        }

        public function getIgnoreHiddenSeries() {
            return $this->ignoreHiddenSeries;
        }

        public function getInverted() {
            return $this->inverted;
        }

        public function getMargin() {
            return $this->margin;
        }

        public function getPlotBackgroundColor() {
            return $this->plotBackgroundColor;
        }

        public function getPlotBackgroundImage() {
            return $this->plotBackgroundImage;
        }

        public function getPlotBorderColor() {
            return $this->plotBorderColor;
        }

        public function getPlotBorderWidth() {
            return $this->plotBorderWidth;
        }

        public function getPlotShadow() {
            return $this->plotShadow;
        }

        public function getShadow() {
            return $this->shadow;
        }

        public function getShowAxes() {
            return $this->showAxes;
        }

        public function getStyle() {
            return $this->style;
        }

        public function getWidth() {
            return $this->width;
        }

        public function getZoomType() {
            return $this->zoomType;
        }

        public function getRenderTo() {
            return $this->renderTo;
        }

        public function getEvents() {
            return $this->events;
        }
        
        public function getCodigoExtra(){
        	return $this->codigoExtra;
        }
        
        public function setRenderTo($renderTo) {
            $this->renderTo = $renderTo;
        }
        

        public function setAlignticks($alignticks) {
            $this->alignticks = $alignticks;
        }

        public function setBackgroundcolor($backgroundcolor) {
            $this->backgroundcolor = $backgroundcolor;
        }

        public function setBorderColor($borderColor) {
            $this->borderColor = $borderColor;
        }

        public function setBorderRadius($borderRadius) {
            $this->borderRadius = $borderRadius;
        }

        public function setBorderWidth($borderWidth) {
            $this->borderWidth = $borderWidth;
        }

        public function setClassName($className) {
            $this->className = $className;
        }

        public function setDefaultSeriesType($defaultSeriesType) {
            $this->defaultSeriesType = $defaultSeriesType;
        }

        public function setHeight($height) {
            $this->height = $height;
        }

        public function setIgnoreHiddenSeries($ignoreHiddenSeries) {
            $this->ignoreHiddenSeries = $ignoreHiddenSeries;
        }

        public function setInverted($inverted) {
            $this->inverted = $inverted;
        }

        public function setMargin($margin) {
            $this->margin = $margin;
        }

        public function setPlotBackgroundColor($plotBackgroundColor) {
            $this->plotBackgroundColor = $plotBackgroundColor;
        }

        public function setPlotBackgroundImage($plotBackgroundImage) {
            $this->plotBackgroundImage = $plotBackgroundImage;
        }

        public function setPlotBorderColor($plotBorderColor) {
            $this->plotBorderColor = $plotBorderColor;
        }

        public function setPlotBorderWidth($plotBorderWidth) {
            $this->plotBorderWidth = $plotBorderWidth;
        }

        public function setPlotShadow($plotShadow) {
            $this->plotShadow = $plotShadow;
        }

        public function setShadow($shadow) {
            $this->shadow = $shadow;
        }

        public function setShowAxes($showAxes) {
            $this->showAxes = $showAxes;
        }

        public function setStyle($style) {
            $this->style = $style;
        }

        public function setWidth($width) {
            $this->width = $width;
        }

        public function setZoomType($zoomType) {
                $this->zoomType = $zoomType;
        }

        public function setEvents($events) {
            $this->events = $events;
        }

        public function setCodigoExtra($codigoExtra){
        	$this->codigoExtra=$codigoExtra;
        }
}

class lang{
	private $decimalPoint;
	private $loading;
	private $months; //[],
	private $resetZoom; 
	private $resetZoomTitle; //Reset zoom level 1:1,
	private $thousandsSep;
	private $weekdays;// []

	
	public function lang($decimalPoint=".",$loading="Loading...",$months=array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'),
						$resetZoom="Reset zoom",$resetZoomTitle="Reset zoom level 1:1",$thousandsSep=",",$weekdays=array('Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado', 'Domingo')){
				
				$this->decimalPoint = $decimalPoint;
				$this->loading = $loading;
				$this->months = $months;
				$this->resetZoom = $resetZoom;
				$this->resetZoomTitle = $resetZoomTitle;
				$this->thousandsSep = $thousandsSep;
				$this->weekdays = $weekdays;
	}

        public function getDecimalPoint() {
            return $this->decimalPoint;
        }

        public function getLoading() {
            return $this->loading;
        }

        public function getMonths() {
            return $this->months;
        }

        public function getResetZoom() {
            return $this->resetZoom;
        }

        public function getResetZoomTitle() {
            return $this->resetZoomTitle;
        }

        public function getThousandsSep() {
            return $this->thousandsSep;
        }

        public function getWeekdays() {
            return $this->weekdays;
        }

        public function setDecimalPoint($decimalPoint) {
            $this->decimalPoint = $decimalPoint;
        }

        public function setLoading($loading) {
            $this->loading = $loading;
        }

        public function setMonths($months) {
            $this->months = $months;
        }

        public function setResetZoom($resetZoom) {
            $this->resetZoom = $resetZoom;
        }

        public function setResetZoomTitle($resetZoomTitle) {
            $this->resetZoomTitle = $resetZoomTitle;
        }

        public function setThousandsSep($thousandsSep) {
            $this->thousandsSep = $thousandsSep;
        }

        public function setWeekdays($weekdays) {
            $this->weekdays = $weekdays;
        }
}

class legend{
	private $backgroundColor;
        private $borderColor;
        private $borderRadius;
        private $borderWidth;
        private $enabled;
        private $itemHiddenStyle;
        private $itemHoverStyle;
        private $itemStyle;
        private $layout;
        private $labelFormatter;
        private $reversed;
        private $shadow;
        private $style_left;
        private $style_right;
        private $style_top;
        private $style_bottom;
        private $symbolPadding;
        private $symbolWidth;

        function __construct($style_left="auto",$style_right="-100px",$style_top="0px",$style_bottom="auto",$backgroundColor="#FFFFFF", $borderColor="#909090", $borderRadius=5, $borderWidth=0, $enabled=true, $itemHiddenStyle="",
                            $itemHoverStyle="", $itemStyle="", $layout="horizontal", $labelFormatter="", $reversed=false, $shadow=true,
                            $style="", $symbolPadding=5, $symbolWidth=30) {
            $this->backgroundColor = $backgroundColor;
            $this->borderColor = $borderColor;
            $this->borderRadius = $borderRadius;
            $this->borderWidth = $borderWidth;
            $this->enabled = $enabled;
            $this->itemHiddenStyle = $itemHiddenStyle;
            $this->itemHoverStyle = $itemHoverStyle;
            $this->itemStyle = $itemStyle;
            $this->layout = $layout;
            $this->labelFormatter = $labelFormatter;
            $this->reversed = $reversed;
            $this->shadow = $shadow;
            $this->style_left = $style_left;
            $this->style_right = $style_right;
            $this->style_top = $style_top;
            $this->style_bottom = $style_bottom;
            $this->symbolPadding = $symbolPadding;
            $this->symbolWidth = $symbolWidth;
        }
        public function getStyle_left() {
            return $this->style_left;
        }

        public function getStyle_right() {
            return $this->style_right;
        }

        public function getStyle_top() {
            return $this->style_top;
        }

        public function getStyle_bottom() {
            return $this->style_bottom;
        }

        public function getBackgroundColor() {
            return $this->backgroundColor;
        }

        public function getBorderColor() {
            return $this->borderColor;
        }

        public function getBorderRadius() {
            return $this->borderRadius;
        }

        public function getBorderWidth() {
            return $this->borderWidth;
        }

        public function getEnabled() {
            return $this->enabled;
        }

        public function getItemHiddenStyle() {
            return $this->itemHiddenStyle;
        }

        public function getItemHoverStyle() {
            return $this->itemHoverStyle;
        }

        public function getItemStyle() {
            return $this->itemStyle;
        }

        public function getLayout() {
            return $this->layout;
        }

        public function getLabelFormatter() {
            return $this->labelFormatter;
        }

        public function getReversed() {
            return $this->reversed;
        }

        public function getShadow() {
            return $this->shadow;
        }

        public function getStyle() {
            return $this->style;
        }

        public function getSymbolPadding() {
            return $this->symbolPadding;
        }

        public function getSymbolWidth() {
            return $this->symbolWidth;
        }

        public function setBackgroundColor($backgroundColor) {
            $this->backgroundColor = $backgroundColor;
        }

        public function setStyle_left($style_left) {
            $this->style_left = $style_left;
        }
        
        public function setStyle_right($style_right) {
            $this->style_right = $style_right;
        }
        
        public function setStyle_top($style_top) {
            $this->style_top = $style_top;
        }
        
        public function setStyle_bottom($style_bottom) {
            $this->style_bottom = $style_bottom;
        }
        

        public function setBorderColor($borderColor) {
            $this->borderColor = $borderColor;
        }

        public function setBorderRadius($borderRadius) {
            $this->borderRadius = $borderRadius;
        }

        public function setBorderWidth($borderWidth) {
            $this->borderWidth = $borderWidth;
        }

        public function setEnabled($enabled) {
            $this->enabled = $enabled;
        }

        public function setItemHiddenStyle($itemHiddenStyle) {
            $this->itemHiddenStyle = $itemHiddenStyle;
        }

        public function setItemHoverStyle($itemHoverStyle) {
            $this->itemHoverStyle = $itemHoverStyle;
        }

        public function setItemStyle($itemStyle) {
            $this->itemStyle = $itemStyle;
        }

        public function setLayout($layout) {
            $this->layout = $layout;
        }

        public function setLabelFormatter($labelFormatter) {
            $this->labelFormatter = $labelFormatter;
        }

        public function setReversed($reversed) {
            $this->reversed = $reversed;
        }

        public function setShadow($shadow) {
            $this->shadow = $shadow;
        }

        public function setStyle($style) {
            $this->style = $style;
        }

        public function setSymbolPadding($symbolPadding) {
            $this->symbolPadding = $symbolPadding;
        }

        public function setSymbolWidth($symbolWidth) {
            $this->symbolWidth = $symbolWidth;
        }
}

class loading{
  private $loading;
  private $hideDuration;
  private $labelStyle;
  private $showDuration;
  private $style;

  function __construct($hideDuration=100, $labelStyle="", $showDuration=100, $style="") {
      $this->loading = $loading;
      $this->hideDuration = $hideDuration;
      $this->labelStyle = $labelStyle;
      $this->showDuration = $showDuration;
      $this->style = $style;
  }

  public function getLoading() {
      return $this->loading;
  }

  public function getHideDuration() {
      return $this->hideDuration;
  }

  public function getLabelStyle() {
      return $this->labelStyle;
  }

  public function getShowDuration() {
      return $this->showDuration;
  }

  public function getStyle() {
      return $this->style;
  }

  public function setLoading($loading) {
      $this->loading = $loading;
  }

  public function setHideDuration($hideDuration) {
      $this->hideDuration = $hideDuration;
  }

  public function setLabelStyle($labelStyle) {
      $this->labelStyle = $labelStyle;
  }

  public function setShowDuration($showDuration) {
      $this->showDuration = $showDuration;
  }

  public function setStyle($style) {
      $this->style = $style;
  }


}

class marker{
    private $enabled;
    private $fillColor;
    private $lineColor;
    private $lineWidth;
    private $radius;

    function __construct($enabled=true, $fillColor="auto", $lineColor="#FFFFFF", $lineWidth=0, $radius=0) {
        $this->enabled = $enabled;
        $this->fillColor = $fillColor;
        $this->lineColor = $lineColor;
        $this->lineWidth = $lineWidth;
        $this->radius = $radius;
    }
    
    public function getEnabled() {
        return $this->enabled;
    }
    
    public function getFillColor() {
        return $this->fillColor;
    }
    
    public function getLineColor() {
        return $this->lineColor;
    }
    
    public function getLineWidth() {
        return $this->lineWidth;
    }
    
    public function getRadius() {
        return $this->radius;
    }
    
    public function setEnabled($enabled) {
        $this->enabled = $enabled;
    }
    
    public function setFillColor($fillColor) {
        $this->fillColor = $fillColor;
    }
    
    public function setLineColor($lineColor) {
        $this->lineColor = $lineColor;
    }
    
    public function setLineWidth($lineWidth) {
        $this->lineWidth = $lineWidth;
    }
    
    public function setRadius($radius) {
        $this->radius = $radius;
    }
    
    
}

class point{

    private $color;
    private $id;
    private $marker;
    private $name;
    private $sliced;
    private $x;
    private $y;
   

    function __construct($color="", $id="", $marker=0, $name="", $sliced=false, $x="", $y="") {
        $this->color = $color;
        $this->id = $id;
        if ($marker == 0) $this->marker = new marker();
        else $this->marker = $marker;
        $this->name = $name;
        $this->sliced = $sliced;
        $this->x = $x;
        $this->y = $y;
    }

    public function getColor() {
        return $this->color;
    }

    public function getId() {
        return $this->id;
    }

    public function getMarker() {
        return $this->marker;
    }

    public function getName() {
        return $this->name;
    }

    public function getSliced() {
        return $this->sliced;
    }

    public function getX() {
        return $this->x;
    }

    public function getY() {
        return $this->y;
    }

    public function setColor($color) {
        $this->color = $color;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setMarker($marker) {
        $this->marker = $marker;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function setSliced($sliced) {
        $this->sliced = $sliced;
    }

    public function setX($x) {
        $this->x = $x;
    }

    public function setY($y) {
        $this->y = $y;
    }

}

class subtitle{
    private $text;
    private $style;
    
    function __construct($text="", $style="") {
        $this->text = $text;
        $this->style = $style;
    }
    
     public function getText() {
         return $this->text;
     }
     
     public function getStyle() {
         return $this->style;
     }
     
     public function setText($text) {
         $this->text = $text;
     }
     
     public function setStyle($style) {
         $this->style = $style;
     }
}


class title{
    private $text;
    private $style;

    function __construct($text="", $style="") {
        $this->text = $text;
        $this->style = $style;
    }

     public function getText() {
         return $this->text;
     }

     public function getStyle() {
         return $this->style;
     }

     public function setText($text) {
         $this->text = $text;
     }

     public function setStyle($style) {
         $this->style = $style;
     }
}

class toolbar{
    private $itemStyle;
    function __construct($itemStyle="") {
        $this->itemStyle = $itemStyle;
    }
    public function getItemStyle() {
        return $this->itemStyle;
    }

    public function setItemStyle($itemStyle) {
        $this->itemStyle = $itemStyle;
    }
}

class tooltip{
    private $backgroundcolor;
    private $bordercolor;
    private $borderradius;
    private $borderwidth;
    private $enabled;
    private $formatter;
    private $shadow;
    private $snap;
    private $style;

    function __construct($backgroundcolor=0, $bordercolor="auto", $borderradius=5, $borderwidth=2,
                         $enabled=true, $formatter=",", $shadow=true, $snap=10, $style="") {
        if ($backgroundcolor == 0) $this->backgroundcolor = "rgba(255, 255, 255, 0.8)";
        else $this->backgroundcolor = $backgroundcolor;
        $this->backgroundcolor = $backgroundcolor;
        $this->bordercolor = $bordercolor;
        $this->borderradius = $borderradius;
        $this->borderwidth = $borderwidth;
        $this->enabled = $enabled;
        $this->formatter = $formatter;
        $this->shadow = $shadow;
        $this->snap = $snap;
        $this->style = $style;
    }

    public function getBackgroundcolor() {
        return $this->backgroundcolor;
    }

    public function getBordercolor() {
        return $this->bordercolor;
    }

    public function getBorderradius() {
        return $this->borderradius;
    }

    public function getBorderwidth() {
        return $this->borderwidth;
    }

    public function getEnabled() {
        return $this->enabled;
    }

    public function getFormatter() {
        return $this->formatter;
    }

    public function getShadow() {
        return $this->shadow;
    }

    public function getSnap() {
        return $this->snap;
    }

    public function getStyle() {
        return $this->style;
    }

    public function setBackgroundcolor($backgroundcolor) {
        $this->backgroundcolor = $backgroundcolor;
    }

    public function setBordercolor($bordercolor) {
        $this->bordercolor = $bordercolor;
    }

    public function setBorderradius($borderradius) {
        $this->borderradius = $borderradius;
    }

    public function setBorderwidth($borderwidth) {
        $this->borderwidth = $borderwidth;
    }

    public function setEnabled($enabled) {
        $this->enabled = $enabled;
    }

    public function setFormatter($formatter) {
        $this->formatter = $formatter;
    }

    public function setShadow($shadow) {
        $this->shadow = $shadow;
    }

    public function setSnap($snap) {
        $this->snap = $snap;
    }

    public function setStyle($style) {
        $this->style = $style;
    }
}

class graphic{
	
        private $legend;
        private $chart;
        private $title;
        private $xAxis;
        private $arrayYAxis;
        private $arraySeries;
        private $subtitle;
        private $export;

        function __construct($legend, $chart, $title, $xAxis, $arrayYAxis, $arraySeries,$subtitle,$export=true) {
            $this->subtitle = $subtitle;
            $this->legend = $legend;
            $this->chart = $chart;
            $this->title = $title;
            $this->xAxis = $xAxis;
            $this->arrayYAxis = $arrayYAxis;
            $this->arraySeries = $arraySeries;
            $this->export = $export;
        }

        public function getLegend() {
        	return $this->legend;
        }

        public function getChart() {
        	return $this->chart;
        }

        public function getTitle() {
        	return $this->title;
        }

        public function getXAxis() {
        	return $this->xAxis;
        }

        public function getArrayYAxis() {
        	return $this->arrayYAxis;
        }

        public function getArraySeries() {
        	return $this->arraySeries;
        }
        
        public function getExport() {
        	return $this->export;
        }

        public function setLegend($legend) {
        	$this->legend = $legend;
        }

        public function setChart($chart) {
        	$this->chart = $chart;
        }

        public function setTitle($title) {
        	$this->title = $title;
        }

        public function setXAxis($xAxis) {
        	$this->xAxis = $xAxis;
        }

        public function setArrayYAxis($arrayYAxis) {
        	$this->arrayYAxis = $arrayYAxis;
        }

        public function setArraySeries($arraySeries) {
        	$this->arraySeries = $arraySeries;
        }
        
        public function setExport($export) {
        	$this->export = $export;
        }
		
        public function pintaLabel($label){
        	echo "labels: {";
        		if(dameCampo("align",$label->getAlign()))echo dameCampo("align",$label->getAlign())."\n";
        		else "align: Right";
        		if(dameCampo("enabled",$label->getEnabled()))echo ",".dameCampo("enabled",$label->getEnabled())."\n";
        		if(dameCampo("formatter",$label->getFormatter()))echo ",".dameCampo("formatter",$label->getFormatter(),2)."\n";
        		if(dameCampo("rotation",$label->getRotation()))echo ",".dameCampo("rotation",$label->getRotation())."\n";
        		if(dameCampo("style",$label->getStyle()))echo ",".dameCampo("style",$label->getStyle(),2)."\n";
        		if($label->getX()!=-8)echo ",".dameCampo("x",$label->getX(),2)."\n";
        		if($label->getY()!=3)echo ",".dameCampo("y",$label->getY(),2)."\n";
        	echo "}\n";
        }
        
        public function pintaXAxis($xAxis){
        	echo "{";
        	if(dameCampo("categories",$xAxis->getCategories()))echo "categories: [".$xAxis->getCategories()."],";
			if(dameCampo("reversed",$xAxis->getReversed()))echo ",reversed: ".$xAxis->getReversed();
			if(dameCampo("offset",$xAxis->getOffset()))echo ",offset: ".$xAxis->getOffset();
			if(dameCampo("type",$xAxis->getType()))echo dameCampo("type",$xAxis->getType())."\n";
			if(dameCampo("maxzoom",$xAxis->getMaxZoom()))echo ",".dameCampo("maxzoom",$xAxis->getMaxZoom())."\n";
			if(dameCampo("tickinterval",$xAxis->getTickInterval()))echo ",".dameCampo("tickinterval",$xAxis->getTickInterval(),2)."\n";
			if($xAxis->getLabels()!=""){
				echo ",";
				$this->pintaLabel($xAxis->getLabels());
			}
			echo "}";
        }
        
        public function pintaYAxis($yAxis){
        	echo "{\n";

        	if($yAxis!=0)
        	{
	        	$this->pintaLabel($yAxis->getLabels());
    	    	//echo ",";
        	}
			echo ",title: {
				text: '".$yAxis->getQueMide()."',
				margin: ".($yAxis->getMargin()-40).",
				style: ".$yAxis->getLabels()->getStyle()."
			}";
			
			if ($yAxis->getMin()!="") echo ",min: ".$yAxis->getMin();
			if ($yAxis->getMax()!="") echo ",max: ".$yAxis->getMax();
            if ($yAxis->getOpposite())  echo ",opposite: true";
            	// else echo "opposite: false";
			if ($yAxis->getOffset() != "-1") echo ",offset:".($yAxis->getOffset());
			echo "}";
        }

       	public function pintaSerie($serie){
       		
            echo "{";
            	if(dameCampo("name",$serie->getName()))echo dameCampo("name",$serie->getName())."\n";
            	if(dameCampo("color",$serie->getColor()))echo ",".dameCampo("color",$serie->getColor())."\n";
            	if(dameCampo("type",$serie->getType()))echo ",".dameCampo("type",$serie->getType())."\n";
            	if(dameCampo("xAxis",$serie->getXAxis()))echo ",".dameCampo("xAxis",$serie->getXAxis())."\n";
            	if(dameCampo("dataParser",$serie->getDataParser()))echo ",".dameCampo("dataparser:",$serie->getDataParser())."\n";
            	if(dameCampo("dataURL",$serie->getDataURL()))echo ",".dameCampo("dataURL",$serie->getDataURL())."\n";
            	if(dameCampo("yAxis",$serie->getYAxis()))echo ",".dameCampo("yAxis",$serie->getYAxis())."\n";
            	if(dameCampo("pointInterval",$serie->getPointInterval()))echo ",".dameCampo("pointInterval",$serie->getPointInterval(),2)."\n";
            	if(dameCampo("pointStart",$serie->getPointStart()))echo ",".dameCampo("pointStart",$serie->getPointStart(),2)."\n";
            	if(dameCampo("data",$serie->getData()))echo ",".dameCampo("data",$serie->getData(),1)."\n";
            	if(dameCampo("visible",$serie->getVisible()))echo ",".dameCampo("visible",$serie->getVisible(),2)."\n";
            echo "}\n"; 
        }
				
		
	public function salidaJavascript(){
            if($this->arraySeries[0]->getData()==""){
                    echo "<div align=\"center\" style=\"font-size:18px;\"><img src=\"./images/warning_32x32.png\"/>No data available for this selection</div>";
            }
            else{
                echo "<script type='text/javascript'>";
				echo "// Apply the grid theme
				Highcharts.setOptions({                
				   colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
				   chart: {
				      backgroundColor: {
				         linearGradient: [0, 0, 0, 0],
				         stops: [
				            [0, 'rgb(255, 255, 255)'],
				            [1, 'rgb(240, 240, 255)']
				         ]
				      },
				
				      plotBackgroundColor: 'rgba(255, 255, 255, .9)',
				      plotShadow: false,
				      plotBorderWidth: 1
				   },\n";
                                
                            if ($this->getExport()) $exp = "true";
                            else                    $exp = "false";
                                   
                            echo " exporting {
                                      enabled: $exp
                                   },\n
 
				   title: {
				      style: {
				         color: '#3E576F',
				         font: 'bold 16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
				      }
				   },
				   subtitle: {
				      style: {
				         color: '#6D869F',
				         font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
				      }
				   },
				   xAxis: {
				      gridLineWidth: 1,
				      lineColor: '#C0D0E0',
				      tickColor: '#C0D0E0',
				      labels: {
				         style: {
				            color: '#666',
				            fontWeight: 'bold'
				         }
				      },
				      title: {
				         style: {
				            color: '#6D869F',
				            font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
				         }            
				      }
				   },
				   yAxis: {
				      alternateGridColor: null,
				      lineColor: '#000',
				      lineWidth: 1,
				      tickWidth: 1,
				      tickColor: '#000',
				      labels: {
				         style: {
				            color: '#666'
				         }
				      },
				      title: {
				         style: {
				            color: '#6D869F',
				            font: 'bold 10px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
				         }            
				      }
				   },
				   legend: {
				      itemStyle: {
				         color: '#3E576F'
				      },
				      itemHoverStyle: {
				         color: 'black'
				      },
				      itemHiddenStyle: {
				         color: 'silver'
				      }
				   },
                
				   credits: {
				      style: {
				         right: '10px'
				      }
				   },";
                                
                            
                                
                               echo 
				   "labels: {
				      style: {
				         color: '#3E576F'
				      }
				   }
				});";
                  $numSeries=count($this->arrayYAxis);
                  if ($_GET['seccion']=='oscilloscope')
                  {
                  	$numSeries=$numSeries+1;
                  }
                  echo "var cursores= new Array;
                  		var numCursores=0;
                  		var numSeries=$numSeries;
                  		var xActual=0;
                  		var yActual=0;
                  		var repintar=false;
                  		var arrayLimitesMax=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
                  		var arrayLimitesMin=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];";
                  echo "function borraPointers(){
							if (document.opciones.checkPunteros.checked)
							{
								chart.series[numSeries].data[1].remove();
								chart.series[$numSeries].data[0].remove();
								chart.redraw();
								var cursores= new Array;
								numCursores=0;
							}
						}";
                  echo "function media(valores){
									var suma=0;
									for(var i=0;i<valores.length;i++){
										suma=suma+valores[i].y;
									}
									return (suma/valores.length);
								}";
                  echo "function redimensionaEjes(){
                  			if(repintar){
                  				//alert ('hola');
	                  			var limitesEje=chart.yAxis[0].getExtremes();
    	              			if(arrayLimitesMax[0]==limitesEje.max)return(0);
								for(var i=0;i<chart.yAxis.length;i++){
	        	          			var limitesEje=chart.yAxis[i].getExtremes();
	            	      			//alert(arrayLimitesMax[i]+':'+limitesEje.max);
	                	  			if(arrayLimitesMax[i]==limitesEje.max)return(0);
	                  				//alert('adios');
									if(arrayLimitesMax[i]==0){
										var mediaEje=media(chart.series[i].data);
		                  				\n
			                  			var diferencia=limitesEje.dataMax-limitesEje.dataMin;
			                  			chart.yAxis[i].setExtremes(limitesEje.dataMin-(mediaEje*2),limitesEje.dataMax+(mediaEje*2));
			                  			var limitesEje=chart.yAxis[i].getExtremes();
										arrayLimitesMax[i]=limitesEje.max;
										arrayLimitesMin[i]=limitesEje.min;	
		            	      		}
		                	  		else
		                  			{
		                  				chart.yAxis[i].setExtremes(arrayLimitesMin[i],arrayLimitesMax[i]);
									}
	                  			}
	                  			repintar=false;
	                  		} 
						}";
                    echo
                           "var chart;
                            $(document).ready(function() {
                            
								function delay(milisegundos){
									var fecha = new Date();
									var curDate = null;
									do { curDate = new Date(); }
									while(curDate-fecha < milisegundos);
								}

                                chart = new Highcharts.Chart({
                                    chart: {
                                        renderTo: '".$this->chart->getRenderTo()."',
                                        margin: [".$this->chart->getMargin()."]";
                                        if(dameCampo("backgroundcolor",$this->chart->getBackgroundcolor()))echo ",".dameCampo("backgroundcolor",$this->chart->getBackgroundcolor())."\n";
                                        echo ",
                                        zoomType: '".$this->chart->getZoomType()."'";
										if(dameCampo("events",$this->chart->getEvents()))echo ",".dameCampo("events",$this->chart->getEvents(),2);										
									echo "}
                                    ,
                                    title: {
                                        text:'".$this->title->getText()."',
                                       style: {".$this->title->getStyle()."}
                                    },
                                    subtitle: {
                                        text:'".$this->subtitle->getText()."',
                                       style: {".$this->subtitle->getStyle()."}
                                    },
                                    
                                    
									plotOptions: {
										line: {
											fillColor: {
												linearGradient: [0, 0, 0, 300],
												stops: [
													[0, '#4572A7'],
													[1, 'rgba(0,0,0,0)']
												]
											},
											lineWidth: 1,
											marker: {
												enabled: false,
												states: {
													hover: {
														enabled: true,
														radius: 3
													}
												}
											},
											shadow: false,
											states: {
												hover: {
													lineWidth: 1						
												}
											}
										}
									},
                                    
									
                                    xAxis: [";
                                        $this->pintaXAxis($this->getXAxis());                                  					
                                    echo "],
                                 yAxis: [";
                                    $primero = 1;
                                    foreach ($this->arrayYAxis as $ejeY) {
                                        if ($primero == 1) { 
                                        	$this->pintaYAxis($ejeY); 
                                        	$primero = 0;
                                        }
                                        else{ 
                                        	echo ","; 
                                        	$this->pintaYAxis($ejeY); 
                                        }
                                    }
                                 echo "],";
                               if($this->xAxis->getType()=="datetime"){
                                 echo "tooltip: {
										formatter: function() {
											var unit = {";
                                                $primero = 1;
                                                foreach ($this->arrayYAxis as $yAxis) {
                                                    if ($primero){ 
                                                        echo "'".$yAxis->getQueMide()."' : '".$yAxis->getUnidadMedida()."'";
                                                        $primero = 0;
                                                    }else{
                                                        echo ",'".$yAxis->getQueMide()."' : '".$yAxis->getUnidadMedida()."'";
                                                    }
                                                }
                                                //Se define la etiqueta por Variable: Hora: y valor:
//										echo "	}[this.series.name];
//											var myArray=(this.x.toString()).split('.');
//											if('".$_GET['seccion']."'!='oscilloscope'){
//												return '<b>'+ (this.point.name || this.series.name) +'</b><br/>'+
//												'Hora: '+Highcharts.dateFormat('%H:%M:%S', this.x) + '<br/>'+
//												'Valor: '+ this.y;
//											}
//											else{
//												return '<b>'+ (this.point.name || this.series.name) +'</b><br/>'+
//												'Time Stamp: '+Highcharts.dateFormat('%M:%S', this.x)+'.'+(this.x.toString()).substring(this.x.toString().length-3,this.x.toString().length) + '<br/>'+
//												'Valor: '+ this.y;
//											}
//
//										}
//								},";
										echo "	}[this.series.name];
											var myArray=(this.x.toString()).split('.');
											if('".$_GET['seccion']."'!='oscilloscope'){
												return '<b>'+ (this.point.name || this.series.name) +'</b><br/>'+
												Highcharts.dateFormat('%H:%M:%S', this.x).toString() + '<br/>'+
												this.y;
											}
											else{
												return '<b>'+ (this.point.name || this.series.name) +'</b><br/>'+
												'Timestamp: '+Highcharts.dateFormat('%M:%S', this.x)+'.'+(this.x.toString()).substring(this.x.toString().length-3,this.x.toString().length) + '<br/>'+
												'Value: '+ this.y;
											}

										}
								},";
                               }
                                echo "legend: {
					layout: '".$this->legend->getLayout()."',
					style: {
						left: '".$this->legend->getStyle_left()."',
						bottom: '".$this->legend->getStyle_bottom()."',
						right: '".$this->legend->getStyle_right()."',
						top: '".$this->legend->getStyle_top()."'
					},
					backgroundColor: '".$this->legend->getBackgroundColor()."'
				},
                                series: [";
                                        $primero = 1;
                                                             
                                        foreach ($this->arraySeries as $serie) {
                                            if ($primero){
											   $primero = 0;
                                            	$this->pintaSerie($serie);
	                                         }else{
                                            	echo ","; $this->pintaSerie($serie);
                                             }
                                        }
                                    echo "
										,{
											visible:true,
											name: 'pointers',
											color: '#4572A7',
											type: 'scatter',";
											if(count($this->arraySeries)>1)echo "yAxis: 0,";
											echo "data: []		
										}
                                    ]";
                           echo" });";
                  				echo $this->chart->getCodigoExtra();
                        echo " });";

                        
                  echo "</script>";
				return $last_serie;
            }
       }
}
?>